package com.zygh.lz.controller;

import com.zygh.lz.entity.Message;
import com.zygh.lz.service.MessageService;
import com.zygh.lz.stapprove.SysPcLog;
import com.zygh.lz.stapprove.ViLog;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "消息通知类", description = "MessageController")
@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;

    //查询所有消息列表
    @ApiOperation("查询所有消息列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "messageState", value = "消息状态", dataType = "int", required = true),
            @ApiImplicitParam(name = "accpetId", value = "消息接收人id", dataType = "int", required = true)})




    //新增消息
    @PostMapping("addMessage")
    //@ViLog(logType = "2",module = "消息列表>新增消息")
    public ResultBean addMessage(@RequestBody Message message, HttpServletRequest request){
        return messageService.addMessage(message);
    }


    //与问题任务关联的消息
    @GetMapping("selectAllByPid")
    //@ViLog(logType = "1",module = "消息列表>查询与问题任务关联的消息")
    public ResultBean selectAllByPid(Integer messagePid, Integer messageType, HttpServletRequest request){
        //request.setAttribute("result",messageService.selectAllByPid(messagePid,messageType));
        return messageService.selectAllByPid(messagePid,messageType);
    }

}
